/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by Administrator on 2017/3/10.
	 */
	var Countdown = __webpack_require__(9);

	var Root = React.createClass({displayName: "Root",
	    onClick:function(){
	        this.refs.clock.stop();
	    },
	    onStart:function(){
	        this.refs.clock.start();
	    },
	    render:function(){
	        var time = new Date().getTime() + 100000;
	        return(
	            React.createElement("div", null, 
	                React.createElement(Countdown, {ref: "clock", timeRemaining: new Date(time), tpl: "{d}天{h}小时{m}分{s}秒"}), 
	                React.createElement("button", {onclick: this.onClick.bind(this)}, "停止"), 
	                React.createElement("button", {onclick: this.onStart.bind(this)}, "开始"), 
	                React.createElement(Countdown, {ref: "clock1", timeRemaining: "2017/04/07", tpl: "{d}天{h}小时{m}分{s}秒"})
	            )
	        )
	    }
	});
	ReactDOM.render(React.createElement(Root, null), document.getElementById('main'));

/***/ },

/***/ 9:
/***/ function(module, exports) {

	/**
	 * Created by DuHuiling on 2017/3/21.
	 */

	var Countdown = React.createClass({displayName: "Countdown",
	    getDefaultProps:function(){
	        return{
	            timeRemaining:"2017-04-01 0:0:0",
	            tpl:"{d}天{h}时{m}分{s}秒",
	            overCallback:function(){}
	        }
	    },
	    countdownTime:null,
	    start:function(){
	        var _this = this;
	        _this.countdownTime = setInterval(function(){
	            _this._init();
	        },1000);
	    },
	    stop:function(){
	        clearTimeout(this.countdownTime);
	    },
	    over:function(){
	        this.stop();
	        console.warn("时间已过");
	        this.props.overCallback();
	    },
	    _init:function(){
	        var _start = new Date(this.props.timeRemaining).getTime(),
	            _now = new Date().getTime(),
	            second = _start - _now;
	        this._countdown(second);
	    },
	    _countdown:function(second){
	        var _node = this.refs.countdown;
	        var _this = this;
	        if(second < 0){
	            _this.over();
	            return;
	        }
	        var _ts = second / 1000 / 60 / 60 % 24,
	            _d = parseInt(second / 1000 / 60 / 60 / 24),    //得到天数
	            _h = parseInt(_ts),      //得到小时
	            _m = parseInt((_ts - _h) * 60),        //得到分钟
	            _s = Math.floor(((_ts - _h) * 60 - _m) * 60);        //得到秒数

	        var format = this.props.tpl, numArr = [], formatArr = [];
	        if(format.indexOf("{d}") >= 0){
	            numArr.push({
	                value:_d,
	                className:"ucs-count-day"
	            });
	        }
	        if(format.indexOf("{h}") >= 0){
	            numArr.push({
	                value:_h,
	                className:"ucs-count-hour"
	            });
	        }
	        if(format.indexOf("{m}") >= 0){
	            numArr.push({
	                value:_m,
	                className:"ucs-count-min"
	            });
	        }
	        if(format.indexOf("{s}") >= 0){
	            numArr.push({
	                value:_s,
	                className:"ucs-count-sec"
	            });
	        }

	        format = format.replace("{d}","-");
	        format = format.replace("{h}","-");
	        format = format.replace("{m}","-");
	        format = format.replace("{s}","-");
	        formatArr = format.split('-');

	        var innHtml = (
	            React.createElement("span", null, 
	                
	                    numArr.map(function(v,index){
	                        var _v = v.value.toString();
	                        return React.createElement("p", null, React.createElement("span", {className: v.className}, _v), formatArr[(index+1)])
	                    })
	                
	            )
	        )

	        ReactDOM.render(innHtml,this.refs.countdown);
	    },
	    componentDidMount:function(){
	        this._init();
	        this.start();
	    },
	    render:function(){
	        return(
	            React.createElement("div", {ref: "countdown", className: "ucs-count"}

	            )
	        )
	    }
	});
	module.exports = Countdown;

/***/ }

/******/ });